package cycling.taxi.com.ui.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.Random;

import butterknife.ButterKnife;
import butterknife.InjectView;
import cycling.taxi.com.R;
import cycling.taxi.com.dialog.AbOnItemClickListener;
import cycling.taxi.com.dialog.AbSlidingPlayView;
import cycling.taxi.com.view.statistical.Anim;
import cycling.taxi.com.view.statistical.Histogram;
import cycling.taxi.com.view.statistical.HistogramData;

/**
 * 保险
 * Created by Administrator on 2017/4/20.
 */
public class InsureFrgt extends Fragment{
    //首页轮播
    private AbSlidingPlayView viewPager;
    /**存储首页轮播的界面*/
    private ArrayList<View> allListView;
    /**首页轮播的界面的资源*/
    private int[] resId = { R.drawable.pingan, R.drawable.renbao, R.drawable.taiping };

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        System.out.println("----保险");

    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.activity_insure, null);
        ButterKnife.inject(this,view);
        initView(view);
        initData();
        return view;

    }
    private void initView(View view) {
        viewPager = (AbSlidingPlayView) view.findViewById(R.id.viewPager_menu);
        //设置播放方式为顺序播放
        viewPager.setPlayType(1);
        //设置播放间隔时间
        viewPager.setSleepTime(2000);
        initViewPager();
    }
    private void initViewPager() {

        if (allListView != null) {
            allListView.clear();
            allListView = null;
        }
        allListView = new ArrayList<View>();

        for (int i = 0; i < resId.length; i++) {
            //导入ViewPager的布局
            View view = LayoutInflater.from(getActivity()).inflate(R.layout.pic_item, null);
            ImageView imageView = (ImageView) view.findViewById(R.id.pic_item);
            imageView.setImageResource(resId[i]);
            allListView.add(view);
        }


        viewPager.addViews(allListView);
        //开始轮播
        viewPager.startPlay();
        viewPager.setOnItemClickListener(new AbOnItemClickListener() {
            @Override
            public void onClick(int position) {
                //跳转到详情界面
                //Intent intent = new Intent(getActivity(), BabyActivity.class);
               // startActivity(intent);
            }
        });
    }

    private void initData() {

    }
    @Override
    public void onDestroy() {
        super.onDestroy();
    }
}
